<template>
  <div class="home">
    <button @click="del">删除第二行</button>
    <button @click="init">数据还原</button>
    <ul>
      <li v-for="(item, index) in showList" :key="index">{{ item }}</li>
    </ul>
  </div>
</template>

<script>
// @ is an alias to /src
import axios from "axios";
export default {
  name: "HomeView",
  components: {},
  data() {
    return {
      list: [], // 总数据
      showList: [], // 展示的数据
    };
  },
  created() {
    axios.get("data.json").then((res) => {
      this.list = res.data;
      this.showList = res.data;
      // console.log(this.list);
    });
  },
  methods: {
    del() {
      this.showList.splice(1, 1);
    },
    init() {
      // console.log("dfghjk");
      this.showList = this.list;
      // console.log(this.showList);
    },
  },
};
</script>
